﻿Public Class CowFieldV2

    Public vChosenFood As Integer
    Private VisualAction As Boolean = False
    Public VisualMouse As Boolean

    Public Property ChosenFood() As Integer
        Get
            Return vChosenFood
        End Get
        Set(ByVal value As Integer)
            vChosenFood = value
        End Set
    End Property

    'Public Sub FeedTime(ByVal status As Boolean)
    '    If (status = True) Then
    '        VisualAction = True
    '        VisualFood.Visible = True
    '        VisualMouse = False
    '        FoodByMouse()
    '    Else
    '        VisualFood.Visible = False
    '        VisualAction = False
    '    End If
    'End Sub

    'Private Sub FoodByMouse()
    '    With VisualFood
    '        .Left = GetP("x") - (.Width / 2)
    '        .Top = GetP("Y") - (.Height / 2)
    '    End With
    'End Sub

    Private Sub CowField_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
        AddFood()
    End Sub

    Public Overloads Sub AddFood()
        Dim p As Point = Me.PointToClient(Control.MousePosition)
        Dim x, y As Integer
        x = p.X
        y = p.Y

        AddFood(x, y)
    End Sub

    Public Overloads Sub AddFood(ByVal x As Integer, ByVal y As Integer)
        '90 75

        Dim FoodStatus As Shop
        Dim foodPrice, GrowType As Integer

        FoodStatus = Parent.Controls.OfType(Of Shop).ElementAtOrDefault(0)

        foodPrice = FoodStatus.FoodPrice
        GrowType = FoodStatus.Chosen

        If (FoodStatus.CheckMoney(foodPrice) = True) Then
            Dim vFood As New Food

            With vFood
                .Left = x - (vFood.Width / 2)
                .Top = y - (vFood.Height / 2)
                .FoodType = GrowType
            End With

            Me.Controls.Add(vFood)
            vFood.BringToFront()

            Parent.Controls.OfType(Of StatusPoints).ElementAtOrDefault(0).DecreaseMoney(foodPrice)
        Else
            FoodStatus.NotEnough()
        End If

    End Sub

    'Private Sub CowField_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
    '    If (VisualAction = True) Then
    '        FoodByMouse()
    '        VisualMouse = True
    '    End If

    '    Dim p As Point = Parent.PointToClient(Control.MousePosition)

    '    If (p.X <= Me.Left Or p.Y <= Me.Top) And VisualMouse = True Then
    '        FeedTime(False)
    '    End If
    'End Sub

    'Private Function GetP(ByVal type As String)
    '    Dim pointer As Point = Me.PointToClient(Control.MousePosition)
    '    Dim result As Integer = 0

    '    type = type.ToUpper()

    '    If (type = "X") Then result = pointer.X
    '    If (type = "Y") Then result = pointer.Y

    '    Return result
    'End Function

    Private Sub CowField_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class
